package com.hehe.controller;


import com.hehe.DTO.Tb_sql_test_DTO;
import com.hehe.Dao.Delete_Mapper;
import com.hehe.Dao.Select_Mapper;
import com.hehe.POJO.Tb_sql_test;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Controller
@RequestMapping(value = "/delete")
public class Delete_by_id {

    @Value("${file.upload.path}")
    private String path;

    @Autowired(required = false)
    private Delete_Mapper delete_mapper;

    @Autowired
    private JdbcTemplate jdbcTemplate;

//    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/");
    /*
    <form  method="post"   action="/upload2"  enctype="multipart/form-data">
        <input type="file" name="uploadFiles" value="请选择文件" multiple>
        <input type="submit" value="上传">
    </form>




     */


    @GetMapping(value = "/{id}")
    @ResponseBody
    public String edit(Model model,  @PathVariable Integer id ) throws JSONException {

        System.out.println();
        System.out.println();
        System.out.println();

        Integer integer = delete_mapper.delete_by_id(id);
        System.out.println("integer = " + integer);
        System.out.println("integer = " + integer);
        System.out.println("integer = " + integer);

        if (integer == 1){
            return "<h1  style='color:green;  '>删除成功</h1>";
        }
        return "<h1  style='color:red;  '>删除 失败 </h1>";
    }


    /*

ysql://localhost:3306/myschool?characterEncoding=utf-8&allowMultiQueries=true


     */







}

